<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title data-i18n="resources.title_themeGridRange"></title>
    <script type="text/javascript" src="../js/include-web.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var map, themeService, themeGridRange, themeParameters, themeLayer,
        url = host + "/iserver/services/map-jingjin/rest/maps/京津地区人口分布图_专题图";
    map = L.map('map', {
        crs: L.CRS.EPSG4326,
        center: [40, 117],
        maxZoom: 18,
        zoom: 6
    });
    new L.supermap.TiledMapLayer(url, {noWrap: true}).addTo(map);
    createTheme();

    function createTheme() {
        themeService = new L.supermap.ThemeService(url);
        var themeGridRangeItem1 = new L.supermap.ThemeGridRangeItem({
                start: -4,
                end: 120,
                color: new L.supermap.ServerColor(198, 244, 240)
            }),

            themeGridRangeItem2 = new L.supermap.ThemeGridRangeItem({
                start: 120,
                end: 240,
                color: new L.supermap.ServerColor(176, 244, 188)
            }),
            themeGridRangeItem3 = new L.supermap.ThemeGridRangeItem({
                start: 240,
                end: 360,
                color: new L.supermap.ServerColor(218, 251, 178)
            }),
            themeGridRangeItem4 = new L.supermap.ThemeGridRangeItem({
                start: 360,
                end: 480,
                color: new L.supermap.ServerColor(220, 236, 145)
            }),
            themeGridRangeItem5 = new L.supermap.ThemeGridRangeItem({
                start: 480,
                end: 600,
                color: new L.supermap.ServerColor(96, 198, 66)
            }),
            themeGridRangeItem6 = new L.supermap.ThemeGridRangeItem({
                start: 600,
                end: 720,
                color: new L.supermap.ServerColor(20, 142, 53)
            }),
            themeGridRangeItem7 = new L.supermap.ThemeGridRangeItem({
                start: 720,
                end: 840,
                color: new L.supermap.ServerColor(85, 144, 55)
            }),

            themeGridRangeItem8 = new L.supermap.ThemeGridRangeItem({
                start: 840,
                end: 960,
                color: new L.supermap.ServerColor(171, 168, 38)
            }),
            themeGridRangeItem9 = new L.supermap.ThemeGridRangeItem({
                start: 960,
                end: 1100,
                color: new L.supermap.ServerColor(235, 165, 9)
            }),
            themeGridRangeItem10 = new L.supermap.ThemeGridRangeItem({
                start: 1100,
                end: 1220,
                color: new L.supermap.ServerColor(203, 89, 2)
            }),
            themeGridRangeItem11 = new L.supermap.ThemeGridRangeItem({
                start: 1220,
                end: 1340,
                color: new L.supermap.ServerColor(157, 25, 1)
            }),
            themeGridRangeItem12 = new L.supermap.ThemeGridRangeItem({
                start: 1340,
                end: 1460,
                color: new L.supermap.ServerColor(118, 15, 3)
            }),
            themeGridRangeItem13 = new L.supermap.ThemeGridRangeItem({
                start: 1460,
                end: 1600,
                color: new L.supermap.ServerColor(112, 32, 7)
            }),

            themeGridRangeItem14 = new L.supermap.ThemeGridRangeItem({
                start: 1600,
                end: 1800,
                color: new L.supermap.ServerColor(106, 45, 12)
            }),
            themeGridRangeItem15 = new L.supermap.ThemeGridRangeItem({
                start: 1800,
                end: 2000,
                color: new L.supermap.ServerColor(129, 80, 50)
            }),
            themeGridRangeItem16 = new L.supermap.ThemeGridRangeItem({
                start: 2000,
                end: 2167,
                color: new L.supermap.ServerColor(160, 154, 146)
            });
        themeGridRange = new L.supermap.ThemeGridRange({
            reverseColor: false,
            rangeMode: L.supermap.RangeMode.EQUALINTERVAL,
            items: [
                themeGridRangeItem1, themeGridRangeItem2,
                themeGridRangeItem3, themeGridRangeItem4,
                themeGridRangeItem5, themeGridRangeItem6,
                themeGridRangeItem7, themeGridRangeItem8,
                themeGridRangeItem9, themeGridRangeItem10,
                themeGridRangeItem11, themeGridRangeItem12,
                themeGridRangeItem13, themeGridRangeItem14,
                themeGridRangeItem15, themeGridRangeItem16
            ]
        });
        themeParameters = new L.supermap.ThemeParameters({
            datasetNames: ["JingjinTerrain"],
            dataSourceNames: ["Jingjin"],
            joinItems: null,
            themes: [themeGridRange]
        });
        themeService.getThemeInfo(themeParameters).then(function (serviceResult) {
            var result = serviceResult.result;
            if (result && result.newResourceID) {
                themeLayer = new L.supermap.TiledMapLayer(url, {
                    noWrap: true,
                    cacheEnabled: false,
                    transparent: true,
                    layersID: result.newResourceID
                }).addTo(map);
            }
        });
    }
</script>
</body>
</html>